package com.example.common;

import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;

public class AppConfig {

    private static AppConfig sInstance;
    private AppConfig() {

    }

    public static AppConfig getInstance() {
        if (sInstance == null) {
            synchronized (AppConfig.class) {
                if (sInstance == null) {
                    sInstance = new AppConfig();
                }
            }
        }
        return sInstance;
    }

    public String getMetaDataString(String key) {
        String data = null;
        try {
            ApplicationInfo appInfo = MyApplication.sInstener.getPackageManager().getApplicationInfo(MyApplication.sInstener.getPackageName(), PackageManager.GET_META_DATA);
            data = appInfo.metaData.getString(key);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return data;
    }

    public int getMetaDataInt(String key) {
        int data = 0;
        try {
            ApplicationInfo appInfo = MyApplication.sInstener.getPackageManager().getApplicationInfo(MyApplication.sInstener.getPackageName(), PackageManager.GET_META_DATA);
            data = appInfo.metaData.getInt(key);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return data;
    }

}
